package luo.Listener;

import luo.entity.Listen;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.monitor.FileAlterationListener;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Author:let_free
 * @Date:2024/6/1/13:26
 **/
//实现ApplicationRunner  在启动Springboot之后立刻启动监听
@Component
public class FileMonitor implements ApplicationRunner {
    @Autowired
    private FileAlterationMonitor monitor;

    public void start() throws Exception {
        monitor.start();
    }

    public void stop() throws Exception {
        monitor.stop();
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        monitor.start();
    }
}
